package com.lc.luzhengtang.adapter;

import android.view.View;
import android.view.ViewGroup;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lc.luzhengtang.R;
import com.lc.luzhengtang.bean.AddressBean;
import com.zcx.helper.scale.ScaleScreenHelperFactory;

import java.util.List;

/**
 * 文 件 名: NewsListAdapter
 * 创 建 人: zhangyu
 * 创建日期: 16/12/24 19:55
 * 邮   箱: yuanchong121@gmail.com
 * 修改时间：
 * 修改备注：
 */
public class AddressListAdapter extends BaseQuickAdapter<AddressBean.DataBean, BaseViewHolder> {

    List<AddressBean.DataBean> data;

    public AddressListAdapter(List<AddressBean.DataBean> data) {

        super(R.layout.item_address_manage, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, final AddressBean.DataBean item) {
        ScaleScreenHelperFactory.getInstance().loadView((ViewGroup) helper.convertView);
//        helper.setText(R.id.text_newstitle, item.getAddress());
        helper.setText(R.id.text_newstime, item.getUsername());
        helper.setText(R.id.text_address, item.getCity()+item.getAddress());
//       helper.setOnItemLongClickListener(R.id.img_changeAddress);
        helper.setText(R.id.text_phone, item.getMobile());
        if (item.getStatus() == 0) {
            helper.setImageResource(R.id.default_address, R.mipmap.checkboxunselected);
            helper.setVisible(R.id.text_default, false);
            helper.setText(R.id.text_default_address, "设为默认地址");
        } else {
            helper.setImageResource(R.id.default_address, R.mipmap.checkboxselected);
            helper.setVisible(R.id.text_default, true);
            helper.setText(R.id.text_default_address, "默认地址");
        }


        helper.addOnClickListener(R.id.img_changeAddress);
        helper.addOnClickListener(R.id.default_address);
        helper.addOnClickListener(R.id.layout_item_recycle);
        View view = helper.getConvertView();
       /* view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
//                intent.putExtra("address",item.getAddress());
                intent.putExtra("username", item.getUsername());
                intent.putExtra("address", item.getAddress());
                intent.putExtra("phone", item.getMobile());
                mContext.startActivity(intent);
            }
        });*/


    }


}
